package com.cskaoyan.controller.wx_order;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.wx_newOrder.MarketOrderGoods;
import com.cskaoyan.service.wx_order.WxOrderServicePartB;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author: Jason 805636901@qq.com
 * @create: 2021-10-24-6:00 PM
 */
@RestController
@RequestMapping("wx/order")
public class WxOrderControllerPartB {



    @Autowired
    WxOrderServicePartB wxOrderServicepartB;

    @RequestMapping("confirm")
    public BaseRespVo confirm(@RequestBody Map map) {
        //SET status401
        Integer orderId = (Integer) map.get("orderId");
        int isCancel = wxOrderServicepartB.confirm(orderId);
        if (isCancel == 0) {
            return BaseRespVo.ok("订单确认失败");
        }
        return BaseRespVo.ok();
    }


    //确认收货商品后 点击评价按钮 回显商品界面
    @RequestMapping("goods")
    public BaseRespVo goods(Integer orderId , Integer goodsId) {
        MarketOrderGoods orderGoodsVO = wxOrderServicepartB.goods(orderId, goodsId);
        return BaseRespVo.ok(orderGoodsVO);
    }


    @RequestMapping("refund")
    public BaseRespVo refund(@RequestBody Map map) {
        //SET status203
        Integer orderId = (Integer) map.get("orderId");
        int isCancel = wxOrderServicepartB.refund(orderId);
        if (isCancel == 0) {
            return BaseRespVo.ok("退款失败");
        }
        return BaseRespVo.ok();
    }


    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody Map map) {
        Integer orderId = (Integer) map.get("orderId");
        int isDelete = wxOrderServicepartB.delete(orderId);
        if (isDelete == 0) {
            return BaseRespVo.ok("订单删除失败");
        }
        return BaseRespVo.ok();
    }


}
